﻿@{    
    //page title
    ViewBag.Title = T("Admin.Configuration.Payment.Methods").Text;
    //active menu item (system name)
    Html.SetActiveMenuItemSystemName("Payment methods");
}

@Html.AntiForgeryToken()
<div class="content-header clearfix">
    <h1 class="pull-left">
        @T("Admin.Configuration.Payment.Methods")
    </h1>
    <div class="pull-right">
       &nbsp;
    </div>
</div>

<div class="content">
    <div class="form-horizontal">
        <div class="panel-group">
            <div class="panel panel-default">
                <div class="panel-body">
                    <div id="paymentmethods-grid"></div>

                    <script>
                        $(document).ready(function() {
                            $("#paymentmethods-grid").kendoGrid({
                                dataSource: {
                                    type: "json",
                                    transport: {
                                        read: {
                                            url: "@Html.Raw(Url.Action("Methods", "Payment"))",
                                            type: "POST",
                                            dataType: "json",
                                            data: addAntiForgeryToken
                                        },
                                        update: {
                                            url: "@Html.Raw(Url.Action("MethodUpdate", "Payment"))",
                                            type: "POST",
                                            dataType: "json",
                                            data: addAntiForgeryToken
                                        }
                                    },
                                    schema: {
                                        data: "Data",
                                        total: "Total",
                                        errors: "Errors",
                                        model: {
                                            id: "SystemName",
                                            fields: {
                                                FriendlyName: { editable: true, type: "string" },
                                                SystemName: { editable: false, type: "string" },
                                                LogoUrl: { editable: false, type: "string" },
                                                SupportCapture: { editable: false, type: "boolean" },
                                                SupportRefund: { editable: false, type: "boolean" },
                                                SupportPartiallyRefund: { editable: false, type: "boolean" },
                                                SupportVoid: { editable: false, type: "boolean" },
                                                RecurringPaymentType: { editable: false, type: "string" },
                                                DisplayOrder: { editable: true, type: "number" },
                                                IsActive: { editable: true, type: "boolean" }
                                            }
                                        }
                                    },
                                    requestEnd: function(e) {
                                        if (e.type == "update") {
                                            this.read();
                                        }
                                    },
                                    error: function(e) {
                                        display_kendoui_grid_error(e);
                                        // Cancel the changes
                                        this.cancelChanges();
                                    },
                                    serverPaging: true,
                                    serverFiltering: true,
                                    serverSorting: true
                                },
                                pageable: {
                                    refresh: true,
                                    numeric: false,
                                    previousNext: false,
                                    info: false,
                                    @Html.Partial("_GridPagerMessages")
                                },
                                editable: {
                                    confirmation: "@T("Admin.Common.DeleteConfirmation")",
                                    mode: "inline"
                                },
                                scrollable: false,
                                columns: [
                                {
                                    field: "FriendlyName",
                                    title: "@T("Admin.Configuration.Payment.Methods.Fields.FriendlyName")",
                                    width: 250
                                }, {
                                    field: "SystemName",
                                    title: "@T("Admin.Configuration.Payment.Methods.Fields.SystemName")",
                                    width: 250
                                }, {
                                    field: "LogoUrl",
                                    title: "@T("Admin.Configuration.Payment.Methods.Fields.Logo")",
                                    width: 100,
                                    template: '<img src="#=LogoUrl#" />'
                                }, {
                                    field: "SupportCapture",
                                    title: "@T("Admin.Configuration.Payment.Methods.Fields.SupportCapture")",
                                    width: 150,
                                    headerAttributes: { style: "text-align:center" },
                                    attributes: { style: "text-align:center" },
                                    template: '# if(SupportCapture) {# <i class="fa fa-check true-icon"></i> #} else {# <i class="fa fa-close false-icon"></i> #} #'
                                }, {
                                    field: "SupportRefund",
                                    title: "@T("Admin.Configuration.Payment.Methods.Fields.SupportRefund")",
                                    width: 100,
                                    headerAttributes: { style: "text-align:center" },
                                    attributes: { style: "text-align:center" },
                                    template: '# if(SupportRefund) {# <i class="fa fa-check true-icon"></i> #} else {# <i class="fa fa-close false-icon"></i> #} #'
                                }, {
                                    field: "SupportPartiallyRefund",
                                    title: "@T("Admin.Configuration.Payment.Methods.Fields.SupportPartiallyRefund")",
                                    width: 150,
                                    headerAttributes: { style: "text-align:center" },
                                    attributes: { style: "text-align:center" },
                                    template: '# if(SupportPartiallyRefund) {# <i class="fa fa-check true-icon"></i> #} else {# <i class="fa fa-close false-icon"></i> #} #'
                                }, {
                                    field: "SupportVoid",
                                    title: "@T("Admin.Configuration.Payment.Methods.Fields.SupportVoid")",
                                    width: 100,
                                    headerAttributes: { style: "text-align:center" },
                                    attributes: { style: "text-align:center" },
                                    template: '# if(SupportVoid) {# <i class="fa fa-check true-icon"></i> #} else {# <i class="fa fa-close false-icon"></i> #} #'
                                }, {
                                    field: "RecurringPaymentType",
                                    title: "@T("Admin.Configuration.Payment.Methods.Fields.RecurringPaymentType")",
                                    width: 250
                                }, {
                                    field: "DisplayOrder",
                                    title: "@T("Admin.Configuration.Payment.Methods.Fields.DisplayOrder")",
                                    //integer format
                                    format: "{0:0}",
                                    width: 150
                                }, {
                                    field: "IsActive",
                                    title: "@T("Admin.Configuration.Payment.Methods.Fields.IsActive")",
                                    width: 100,
                                    headerAttributes: { style: "text-align:center" },
                                    attributes: { style: "text-align:center" },
                                    template: '# if(IsActive) {# <i class="fa fa-check true-icon"></i> #} else {# <i class="fa fa-close false-icon"></i> #} #'
                                }, {
                                    field: "SystemName",
                                    title: "@T("Admin.Configuration.Payment.Methods.Configure")",
                                    width: 150,
                                    template: '<a class="btn btn-default" href="ConfigureMethod?systemName=#=SystemName#"><i class="fa fa-cog"></i>@T("Admin.Configuration.Payment.Methods.Configure")</a>'
                                }, {
                                    command: {
                                        name: "edit",
                                        text: {
                                            edit: "@T("Admin.Common.Edit")",
                                            update: "@T("Admin.Common.Update")",
                                            cancel: "@T("Admin.Common.Cancel")"
                                        }
                                    },
                                    title: "@T("Admin.Common.Edit")",
                                        width: 150
                                    }
                                ]
                            });
                        });
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>